<template>
  <img id="barcode" />
</template>

<script>
import JsBarcode from "jsbarcode";

export default {
  name: "BarCode",
  props: {
    value: {
      type: String,
      require: true,
    },
    options: {
      type: Object,
      default: () => ({}),
    },
  },
  mounted() {
    JsBarcode("#barcode", this.value);
  },
  watch: {
    value(newVal) {
      JsBarcode("#barcode", newVal, this.options);
    },
    options(newVal) {
      JsBarcode("#barcode", this.value, newVal);
    },
  },
};
</script>

<style></style>
